<script setup lang="ts">
/*
 * @description:会员表
 * @author: lxx
 * @date: 2025-7-22
 * @version: V1.0.0
 */
import { dataSaveApi } from '@/api/member'
import type { ItemFormInt } from '@/api/member/types'
import { useAddEdit } from '@/hooks/system/useFramework'
import constants from '@/common/constant'
const dataFormRef = ref()
const formData = ref<ItemFormInt>({
  /** ID */
  id: -1,

  /** 姓名 */
  username: '',

  /** 电话 */
  phone: '',

  /** 性别 */
  sex: '',

  /** 会员等级 */
  memberlevel: '',

  /** 余额 */
  balance: '',

  /** 备注 */
  memo: ''
})
const { loading, dialog, open, handleSubmitClick, handleCloseDialog } = useAddEdit<ItemFormInt>(dataSaveApi, formData, dataFormRef)

const rules = {
  /** ID */
  id: [{ required: true, message: '请输入ID', trigger: 'blur' }],
  /** 姓名 */
  username: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
  /** 电话 */
  // phone: [
  //   { required: true, message: '请输入电话', trigger: 'blur' },
  //   {
  //     pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
  //     message: '请输入正确的手机号码',
  //     trigger: 'blur'
  //   }
  // ],
  /** 性别 */
  sex: [{ required: true, message: '请输入性别', trigger: 'blur' }]
  /** 会员等级 */
  //   memberlevel: [{ required: true, message: '请输入会员等级', trigger: 'blur' }],
  /** 余额 */
  //   balance: [{ required: true, message: '请输入余额', trigger: 'blur' }],
  /** 备注 */
  //   memo: [{ required: true, message: '请输入备注', trigger: 'blur' }],
}
defineExpose({
  open
})
</script>
<template>
  <!--字典弹窗-->
  <el-dialog append-to-body v-loading="loading" v-model="dialog.visible" :title="dialog.title" width="500px" @close="handleCloseDialog">
    <el-form ref="dataFormRef" :model="formData" :rules="rules" label-width="80px">
      <el-form-item label="姓名" prop="username">
        <el-input v-model="formData.username" placeholder="请输入姓名" />
      </el-form-item>

      <el-form-item label="电话" prop="phone">
        <el-input v-model="formData.phone" placeholder="请输入电话" />
      </el-form-item>

      <el-form-item label="性别" prop="sex">
        <!-- <el-input v-model="formData.sex" placeholder="请输入性别" /> -->
        <Dict :code="constants.SEX" v-model="formData.sex" type="radio" />
      </el-form-item>
      <!-- <el-form-item label="会员等级" prop="memberlevel">
        <el-input v-model="formData.memberlevel" placeholder="请输入会员等级" />
      </el-form-item>

      <el-form-item label="余额" prop="balance">
        <el-input v-model="formData.balance" placeholder="请输入余额" />
      </el-form-item> -->
      <el-form-item label="备注" prop="memo">
        <el-input v-model="formData.memo" placeholder="请输入备注" />
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button type="primary" @click="handleSubmitClick()">确 定</el-button>
        <el-button @click="handleCloseDialog()">取 消</el-button>
      </div>
    </template>
  </el-dialog>
</template>
<style lang="scss" scoped></style>
